<?php
/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Results
 *
 * @author fun
 */
class Results {

  public static function getDatesForTrimesters($year, $trimesters)
  {
    $minMonthDay = array(
        '1' => '01-01',
        '2' => '04-01',
        '3' => '07-01',
        '4' => '10-01',
    );

    $maxMonthDay = array(
        '1' => '03-31',
        '2' => '06-30',
        '3' => '09-30',
        '4' => '12-31',
    );

    $isFirst = true;
        
    foreach($trimesters as $trimester)
    {
      if($isFirst)
      {
        $isFirst = false;
        $minDate = $year . "_" . $minMonthDay[$trimester];
      }

      if(in_array($trimester + 1, $trimesters))
      {
        continue;
      }
      else
      {
        $maxDate = $year . "_" . $maxMonthDay[$trimester];
      }
    }
    
    return array('min' => $minDate, 'max' => $maxDate);
  }

}

?>
